{% extends "base_facebook.html" %}
{% block title %}Enter the competition{% endblock %}
{% block body %}entry{% endblock %}

{% block page_content %}
    <header class="tab-header">
        <h1><b>WIN</b> a {{ competition.university.name }} Graduate Hoody</h1>
    </header>
    <section class="app-content">
        <div class="highlighted">
            <p>
                To celebrate the launch of our new Graduate range, we’re giving away
                10 {{ competition.university.name }} hoodies absolutely free.
            </p>
        </div>
        <p>
            Simply enter the prize draw below and we’ll randomly select 2 
            winners every fortnight from {{ competition.opening_date|date:"l jS M" }}. Good luck!
        </p>
        <span class="arrow-seperator"></span>
        <section id="testimonials" class="module-box hoody-box">
            <header class="top">
                <h3>Entry form</h3>
            </header>
            <section class="content">
                <form id="frm-enter" action="." method="POST" accept-charset="utf-8">
                    {% csrf_token %}
                    {% form_errors form %}
                    <ul class="list-form">
                        <li>
                            {{ form.name.label_tag }}
                            {{ form.name }}
                        </li>
                        <li>
                            {{ form.email.label_tag }}
                            {{ form.email }}
                        </li>
                        <li>
                            {{ form.email_confirm.label_tag }}
                            {{ form.email_confirm }}
                        </li>
                        <li>
                            <label for="id_size">Select a size (<a href="{{ competition.university.hoodySizeGuideUrl }}" target="_blank" title="(opens in new window)">see size guide</a>)</label>
                            {{ form.size }}
                        </li>
                        <li>
                            {{ form.t_and_cs }}
                            <label for="id_t_and_cs">I agree to the <a href="{{ competition.university.terms }}" target="_blank" title="(opens in new window)">Terms and Conditions</a></label>
                        </li>
                    </ul>
                    <button type="submit" class="btn">Enter draw</button>
                </form>
                <img class="hoody" src="{{ settings.MEDIA_URL }}{{ competition.university.entryImage }}" height="300" width="217">
                <a class="full-size" href="{{ competition.university.fullSizeLink }}" title="(opens in a new window)" target="_blank">See fullsize image</a>
                <a class="share">share</a>
            </section>
        </section>
    </section>
{% endblock page_content %}

{% block footer_script %}
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>

    FB._https = true;
    FB.init({
        appId  : '{{ competition.app_id }}',
        status : false,
        cookie : false,
        xfbml  : true
    });

    window.fbAsyncInit = function() {
        //FB.Canvas.setAutoGrow();
        FB.Canvas.setSize({ width: 520, height: 1300 });
    }

    //click for fb dialog in global.js
    /*
     * shareClick is invoked (from globals.js) when the .share-link is clicked.
     */
    function shareClick(){
        FB.ui( {
            {% include "facebook/templates/_share.html" %}
        });
    }

    function scrollTop(){
        FB.Canvas.scrollTo(0,0);
    }
    
    $('a.share').click(function(){
        shareClick();
    });

    $(document).ready(function(){
    	scrollTop();
    });

</script>
{% endblock footer_script %}
